# -*- coding: utf-8 -*-

"""
TigerGraph reserved keywords

when encountered as an identifier (property name) we need to change them, like appending an underscore to the name
"""

TG_RESERVED = set("""_SUBSTRING
ABORT
ACCESS
ADD
ADMIN
AFTER
ALL
ALLOCATE
ALTER
ANALYZE
AND
ANY
APPROX_COUNT
ARCHIVE
ARE
ARRANGE
ARRAY
AS
ASC
ASENSITIVE
ASYMMETRIC
AT
ATOMIC
ATTRIBUTE
AUTHORIZATION
AV
AVG
BAG
BEFORE
BEGIN
BETWEEN
BIGINT
BINARY
BINSTORAGE
BLOB
BOOL
BOOLEAN
BOTH
BUCKET
BUCKETS
BY
BYTEARRAY
CACHE
CALL
CALLED
CASCADE
CASCADED
CASE
CAST
CAT
CD
CHANGE
CHAR
CHARACTER
CHARARRAY
CHECK
CLEAR
CLOB
CLOSE
CLUSTER
CLUSTERED
CLUSTERSTATUS
COGROUP
COLLATE
COLLECTION
COLUMN
COLUMNS
COMMIT
COMPACT
COMPACTIONS
COMPRESS
COMPUTE
CONCAT
CONCATENATE
CONF
CONNECT
CONST
CONSTRAINT
CONTINUE
COPYFROMLOCAL
COPYTOLOCAL
CORRESPONDING
COUNT
CP
CREATE
CROSS
CUBE
CURRENT
CURRENT_DATE
CURRENT_PATH
CURRENT_ROLE
CURRENT_TIME
CURRENT_TIMESTAMP
CURRENT_USER
CURSOR
CYCLE
DATA
DATA_SOURCE
DATABASE
DATABASES
DATE
DATETIME
DAY
DBPROPERTIES
DD
DEALLOCATE
DEC
DECIMAL
DECLARE
DECRYPT
DEFAULT
DEFERRED
DEFINE
DEFINED
DELETE
DELIMITED
DEPENDENCY
DEREF
DESC
DESCRIBE
DETERMINISTIC
DIFF
DIRECTED
DIRECTORIES
DIRECTORY
DISABLE
DISCONNECT
DISTINCT
DISTRIBUTE
DISTRIBUTED
DM
DO
DOUBLE
DROP
DRYRUN
DU
DUMP
DYNAMIC
EACH
EDGE
ELEMENT
ELEM_TYPE
ELSE
ELSEIF
EMPTY
ENABLE
END
EOL
ESCAPE
ESCAPED
EVAL
EXCEPT
EXCHANGE
EXCLUSIVE
EXEC
EXECUTE
EXISTS
EXIT
EXPLAIN
EXPORT
EXTENDED
EXTERN
EXTERNAL
FALSE
FETCH
FIELDS
FILE
FILEFORMAT
FILENAME
FILTER
FIRST
FIXED_BINARY
FLATTEN
FLATTEN_JSON_ARRAY
FLOAT
FOLLOWING
FOR
FOREACH
FOREIGN
FORMAT
FORMATTED
FREE
FROM
FULL
FUNCTION
FUNCTIONS
GENERATE
GET
GLOBAL
GPATH
GPATH_QUERY
GQL
GQUERY
GRANT
GRAPH
GROUP
GROUPING
GSHELL
HANDLER
HARD
HASH_PARTITION
HAVING
HEADER
HELP
HOLD
HOLD_DDLTIME
HOST_GRAPH
HOUR
ICON
IDENTIFIED
IDENTITY
IDXPROPERTIES
IF
IGNORE
ILLUSTRATE
IMMEDIATE
IMPORT
IN
INCREMENTAL
INDEX
INDEXES
INDICATOR
INIT
INNER
INOUT
INPATH
INPUT
INPUTDRIVER
INPUTFORMAT
INPUT_LINE_FILTER
INSENSITIVE
INSERT
INSTALL
INT
INT16
INT32
INT32_T
INT64_T
INT8
INTEGER
INTERPRET
INTERSECT
INTERVAL
INTO
INT_LIST
INT_SET
IS
ITEMS
ITERATE
JAR
JOB
JOIN
JSON
KAFKA
KEY
KEYS
KEY_TYPE
KILL
LANGUAGE
LARGE
LATERAL
LEADING
LEAVE
LEFT
LESS
LIKE
LIMIT
LINES
LISTLOAD
LOADING
LOCAL
LOCALTIME
LOCALTIMESTAMP
LOCK
LOCKS
LOGICAL
LONG
LOOP
LS
MACRO
MAP
MAPJOIN
MATCH
MATCHES
MATERIALIZED
MAX
MEMBER
MERGE
METHOD
MIN
MINUS
MINUTE
MKDIR
MODIFIES
MODULE
MONTH
MSCK
MULTISET
MV
NATIONAL
NATURAL
NCHAR
NCLOB
NEW
NO
NOPRINT
NONE
NOSCAN
NOT
NO_DROP
NULL
NUMERIC
OF
OFFLINE
OFFLINE2ONLINE
OLD
ON
ONLINE_POST
ONLY
ONSCHEMA
OPEN
OPTIMIZE
OPTION
OR
ORDER
OUT
OUTER
OUTPUT
OUTPUTDRIVER
OUTPUTFORMAT
OVER
OVERLAPS
OVERWRITE
OWNER
PARALLEL
PARAMETER
PARTIALSCAN
PARTITION
PARTITIONED
PARTITIONS
PASSWORD
PERCENT
PIG
PIGDUMP
PIGSTORAGE
PLUS
PRECEDING
PRECISION
PREPARE
PRESERVE
PRETTY
PRIMARY
PRIMARY_ID
PRINCIPALS
PROCEDURE
PROTECTION
PROXY
PURGE
PWD
QUERY
QUIT
QUOTE
RANGE
RANGE_PARTITION
READ
READONLY
READS
REAL
REBUILD
RECOMPILE
RECORDREADER
RECORDWRITER
RECURSIVE
REDUCE
REF
REFERENCES
REFERENCING
REFRESH
REGEXP
REGISTER
RELEASE
RENAME
REPAIR
REPEAT
REPLACE
RESIGNAL
RESTRICT
RESULT
RESUME
RETURN
RETURNS
REVERSE_EDGE
REVOKE
REWRITE
RIGHT
RLIKE
RM
RMF
ROLE
ROLES
ROLLBACK
ROLLUP
ROW
ROWS
RUN
S3
SAMPLE
SAVEPOINT
SCHEMA
SCHEMAS
SCHEMA_CHANGE
SCOPE
SCROLL
SEARCH
SECOND
SECONDARY_ID
SECRET
SELECT
SEMI
SENSITIVE
SEPARATOR
SERDE
SERDEPROPERTIES
SERVER
SESSION_USER
SET
SETS
SHARED
SHIP
SHOW
SHOW_DATABASE
SIGNAL
SIMILAR
SIZE
SKEWED
SMALLINT
SOME
SORT
SORTED
SPECIFIC
SPECIFICTYPE
SPLIT
SQL
SQLEXCEPTION
SQLSTATE
SQLWARNING
SSL
START
START_ID
STATIC
STATISTICS
STATUS
STATS
STDERR
STDIN
STDOUT
STORE
STORED
STREAM
STREAMTABLE
STRING
STRING_LIST
STRING_SET
STRUCT
SUBMULTISET
SUM
SYMMETRIC
SYSTEM
SYSTEM_USER
SYS.FILE_NAME
SYS.INTERNAL_ID
TABLE
TABLES
TABLESAMPLE
TBLPROPERTIES
TEMPORARY
TEMP_TABLE
TERMINATED
TEXTLOADER
THEN
THROUGH
TIME
TIMESTAMP
TIMEZONE_HOUR
TIMEZONE_MINUTE
TINYINT
TO
TOKEN
TOKENIZE
TOKEN_LEN
TOUCH
TO_FLOAT
TO_INT
TRAILING
TRANSACTION
TRANSACTIONS
TRANSFORM
TRANSLATION
TREAT
TRIGGER
TRUE
TRUNCATE
TUPLE
TYPE
TYPEDEF
UDF_PARTITION
UINT
UINT16
UINT32
UINT32_T
UINT64_T
UINT8
UINT8_T
UINT_SET
UNARCHIVE
UNBOUNDED
UNDIRECTED
UNDO
UNION
UNIONTYPE
UNIQUE
UNIQUEJOIN
UNKNOWN
UNLOCK
UNNEST
UNSET
UNSIGNED
UNTIL
UPDATE
UPSERT
URI
USE
USER
USING
UTC
UTCTIMESTAMP
VAL
VALUE
VALUES
VALUE_TYPE
VARCHAR
VARYING
VECTOR
VERSION
VERTEX
VIEW
VOID
WHEN
WHENEVER
WHERE
WHILE
WINDOW
WITH
WITHIN
WITHOUT
YEAR
CURRENT_TRANSFORM_GROUP_FOR_TYPE
UINT32_UDT_KV_LIST
INT32_INT32_KV_LIST
UINT32_UINT32_KV_LIST
CURRENT_DEFAULT_TRANSFORM_GROUP""".split('\n'))


def is_keyword(s):
    return s.upper() in TG_RESERVED
